package com.youlai.boot.system.service.order;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.youlai.boot.common.exception.BusinessException;
import com.youlai.boot.system.model.entity.LpsWl;
import com.youlai.boot.system.model.vo.LJOrderExcelVO;
import com.youlai.boot.system.model.vo.LpsOrderLjVO;
import com.youlai.boot.util.MapUtils;
import com.youlai.boot.util.NumberUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Service
@Slf4j
public class LJOrderHandle {
    public final static String TK = "TK";
    public final static String TK_1 = "轿厢深度 TK";
    public final static String BK = "BK";
    public final static String GRP_WALL_BASE_TYPE_LEFT = "GRP_WALL_BASE_TYPE_LEFT";
    public final static String GRP_WALL_BASE_TYPE_RIGHT = "GRP_WALL_BASE_TYPE_RIGHT";
    public final static String WALL_BASE_THICKNESS_LEFT = "WALL_BASE_THICKNESS_LEFT";
    public final static String GRP_HANDRAIL_FINISH = "GRP_HANDRAIL_FINISH";
    public final static String GRP_COP_TKT1 = "GRP_COP_TKT1";
    public final static String GRP_COP_TKT2 = "GRP_COP_TKT2";
    public final static String GRP_COP_TKT3 = "GRP_COP_TKT3";
    public final static String GRP_COP_TKT4 = "GRP_COP_TKT4";
    public final static String HANDRAIL_LEFT = "HANDRAIL_LEFT";
    public final static String HANDRAIL_RIGHT = "HANDRAIL_RIGHT";
    public final static String TKWO_RIGHT = "TKWO_RIGHT";
    public final static String TKWC_RIGHT = "TKWC_RIGHT";
    public final static String TKWO_LEFT = "TKWO_LEFT";
    public final static String TKWC_LEFT = "TKWC_LEFT";
    public final static String NO_57863882 = "57863882";
    public final static String NO_57628558 = "57628558";
    public final static String NO_57863883 = "57863883";
    public final static String NO_57863727 = "57863727";
    public final static String NO_57863726 = "57863726";
    public final static String NO_57863728 = "57863728";

    /**
     * @param objList
     * @param lpsWlMap
     * @return
     */
    public List<LpsOrderLjVO> handle(List<LJOrderExcelVO> objList, Map<String, LpsWl> lpsWlMap) {
        if (CollectionUtil.isEmpty(objList)) {
            return CollectionUtil.newArrayList();
        }
        List<LpsOrderLjVO> list = objList.stream().map(item -> {
            // 如果物料是利居或者利居 则特殊处理
            LpsOrderLjVO order = new LpsOrderLjVO();
            BeanUtils.copyProperties(item, order);
            if (Objects.nonNull(lpsWlMap.get(order.getWl()))) {
                order.setBz(lpsWlMap.get(order.getWl()).getRemark());
            }
            Map<String, String> featureMap = MapUtils.getFeatureMap(item.getTz());
            switch (order.getWl()) {
                case NO_57863882:
                    NO_57863882(featureMap, order);
                    break;
                case NO_57628558:
                    NO_57628558(featureMap, order);
                    break;
                case NO_57863883:
                    NO_57863883(featureMap, order);
                    break;
                case NO_57863727:
                    NO_57863727(featureMap, order);
                    break;
                case NO_57863726:
                    NO_57863726(featureMap, order);
                    break;
                case NO_57863728:
                    NO_57863728(featureMap, order);
                    break;
                default:
                    log.error("【利居】解析到未知的物料{}", order.getWl());
            }
            order.setId(IdUtil.getSnowflakeNextId());
            if (StrUtil.isNotBlank(order.getKja())) {
                //去掉小数点及小数点后面的多个0
                order.setKja(removeTrailingZerosIfInteger(order.getKja()));
            }
            if (StrUtil.isNotBlank(order.getFszd())) {
                order.setFszd(removeTrailingZerosIfInteger(order.getFszd()));
            }
            if (StrUtil.isNotBlank(order.getFszd())) {
                order.setFszd(removeTrailingZerosIfInteger(order.getFszd()));
            }
            if (StrUtil.isNotBlank(order.getGrpCopTkt1())) {
                order.setGrpCopTkt1(removeTrailingZerosIfInteger(order.getGrpCopTkt1()));
            }
            if (StrUtil.isNotBlank(order.getGrpCopTkt2())) {
                order.setGrpCopTkt2(removeTrailingZerosIfInteger(order.getGrpCopTkt2()));
            }
            if (StrUtil.isNotBlank(order.getGrpCopTkt3())) {
                order.setGrpCopTkt3(removeTrailingZerosIfInteger(order.getGrpCopTkt3()));
            }
            if (StrUtil.isNotBlank(order.getGrpCopTkt4())) {
                order.setGrpCopTkt4(removeTrailingZerosIfInteger(order.getGrpCopTkt4()));
            }
            return order;
        }).toList();
        return list;
    }

    public static String removeTrailingZerosIfInteger(String numberStr) {
        try {
            BigDecimal value = new BigDecimal(numberStr);
            if (value.scale() <= 0 || value.stripTrailingZeros().scale() <= 0) {
                value = value.stripTrailingZeros().setScale(0);
            }
            return value.toString();
        } catch (NumberFormatException e) {
            return numberStr; // 如果不是数字，返回原始字符串
        }
    }

    /**
     * TODO 待确认
     * 类型一： (WALL_BASE_TYPE_LEFT < 4 或 WALL_BASE_TYPE_RIGHT < 4)
     * 1100<=TK<=1500, L=TK-520. A=TK/2-165
     * TK=1600, L=970.A=740
     * TK=1900, L=1142.A=890
     * TK=2100, L=1194.A=990
     * 类型二：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6 ) 或(WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6 ) 和 (COP_TKT1 >=1 或 COP_TKT2>= 1)
     * TK=1400, L=650.A=400
     * TK=1500, L=750.A=450
     * TK=1600, L=830.A=600
     * TK=1900, L=1080.A=830
     * TK=2100, L=1150.A=950
     * 类型三：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6 ) 或 (WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6)和(COP_TKT1 =0 和COP_TKT4=0) 和 HANDRAIL_LEFT = 9) 或(COP_TKT2= 0 和 COP_TKT3 =0) 和 HANDRAIL_RIGHT = 9))
     * TK >= 1250 和 TK<=1500, L=TK-644. A=TK/2-210
     * TK=1600, L=970.A=740
     * TK=1900, L=1142.A=890
     * TK=2100, L=1194.A=990
     * 通用：
     * GRP_HANDRAIL_FINISH:SS304_BRUS或GRP_HANDRAIL_FINISH:SS304_HAIR     拉丝
     * GRP_HANDRAIL_FINISH:SS304_MIRR或GRP_HANDRAIL_FINISH:SS304_POLISH   镜面
     * GRP_HANDRAIL_FINISH:SS304_PAINT或GRP_HANDRAIL_FINISH:SS304_R9006    喷粉
     * 此款固定支架数量没有变值，估输出固定都为：固定支架数量：2
     * 注1：以上红色字为抓取信息，绿色为输出信息
     * 注2：如下为对应订单参数数字
     * Wall_Base_Type_Left PB对应数字1
     * Wall_Base_Type_Left HC对应数字2
     * Wall_Base_Type_Left AC对应数字3
     * Wall_Base_Type_Left SS 对应数字4 WALL_BASE_THICKNESS_LEFT = 1.0
     * Wall_Base_Type_Left ST 对应数字5
     * Wall_Base_Type_Left SS 对应数字6 WALL_BASE_THICKNESS_LEFT = 1.2
     * Wall_Base_Type_Right PB对应数字1
     * Wall_Base_Type_Right HC对应数字2
     * Wall_Base_Type_Right AC对应数字3
     * Wall_Base_Type_Right SS对应数字4 (WALL_BASE_THICKNESS_LEFT = 1.0)
     * Wall_Base_Type_Right ST 对应数字5
     * Wall_Base_Type_Right SS 对应数字6 (WALL_BASE_THICKNESS_LEFT = 1.2)
     * COP_TKT1或2或3或4=N                           对应数字0
     * COP_TKT1或2或3或4=COP GS 100 SF                 对应数字1
     * COP_TKT1或2或3或4=COP_GS_120_SF              对应数字2
     * COP_TKT1或2或3或4=COP_GS 100 SF_FH            对应数字3
     * COP_TKT1或2或3或4=COP_GS_100_SF_FH_PORT     对应数字4
     * COP_TKT1或2或3或4=X                         对应数字5
     * COP_TKT1或2或3或4=COP_GS_300_FL_FH         对应数字6
     * COP_TKT1或2或3或4=COP_GS_100_FL_FH         对应数字7
     *
     * @param featureMap
     * @param order
     */
    private void NO_57863728(Map<String, String> featureMap, LpsOrderLjVO order) {
        try {
            order.setTk(NumberUtils.extractValueStr(featureMap.getOrDefault(TK_1, "")));
            order.setGrpWallBaseTypeLeft(featureMap.getOrDefault(GRP_WALL_BASE_TYPE_LEFT, ""));
            order.setGrpWallBaseTypeRight(featureMap.getOrDefault(GRP_WALL_BASE_TYPE_RIGHT, ""));
            order.setBmcl(getBmcl(featureMap.getOrDefault(GRP_HANDRAIL_FINISH, "")));
            order.setGrpCopTkt1(getValue(featureMap.getOrDefault(GRP_COP_TKT1, "")) + "");
            order.setGrpCopTkt2(getValue(featureMap.getOrDefault(GRP_COP_TKT2, "")) + "");
            order.setGrpCopTkt3(getValue(featureMap.getOrDefault(GRP_COP_TKT3, "")) + "");
            order.setGrpCopTkt4(getValue(featureMap.getOrDefault(GRP_COP_TKT4, "")) + "");
            order.setGdzjsl("2");  //此款固定支架数量没有变值，估输出固定都为：固定支架数量：2

            Integer handrailLeft = null;
            String handrailLeftStr = featureMap.getOrDefault(HANDRAIL_LEFT, "");
            if (StrUtil.isNotBlank(handrailLeftStr)) {
                try {
                    handrailLeft = Integer.parseInt(handrailLeftStr);
                } catch (Exception e) {
                    handrailLeft = -999;
                    log.error("【利居】HANDRAIL_LEFT 解析到未知的物料{}", order.getWl());
                }
            }

            Integer handrailRight = null;
            String handrailRightStr = featureMap.getOrDefault(HANDRAIL_RIGHT, "");
            if (StrUtil.isNotBlank(handrailRightStr)) {
                try {
                    handrailRight = Integer.parseInt(handrailRightStr);
                } catch (Exception e) {
                    handrailRight = -999;
                    log.error("【利居】HANDRAIL_RIGHT 解析到未知的物料{}", order.getWl());
                }
            }

            if (StrUtil.isBlank(order.getTk())) {
                order.setBz("错误:TK为空");
                return;
            }
            if (StrUtil.isBlank(order.getGrpWallBaseTypeLeft())) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_LEFT为空");
                return;
            }
            if (StrUtil.isBlank(order.getGrpWallBaseTypeRight())) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_RIGHT为空");
                return;
            }
            Integer leftValue = getValue(order.getGrpWallBaseTypeLeft(), featureMap.getOrDefault(WALL_BASE_THICKNESS_LEFT, ""));
            if (leftValue == -1) {
                order.setBz("错误:WALL_BASE_THICKNESS_LEFT匹配不到对应数字");
                return;
            }
            order.setGrpWallBaseTypeLeft(leftValue + "");
            Integer rightValue = getValue(order.getGrpWallBaseTypeRight(), featureMap.getOrDefault(WALL_BASE_THICKNESS_LEFT, ""));
            if (rightValue == -1) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_RIGHT匹配不到对应数字");
                return;
            }
            order.setGrpWallBaseTypeRight(rightValue + "");

            if (order.getGrpCopTkt1().equals("-1")) {
                order.setBz("错误:GRP_COP_TKT1匹配不到对应数字");
                return;
            }
            if (order.getGrpCopTkt2().equals("-1")) {
                order.setBz("错误:GRP_COP_TKT2匹配不到对应数字");
                return;
            }
            if (order.getGrpCopTkt3().equals("-1")) {
                order.setBz("错误:GRP_COP_TKT3匹配不到对应数字");
                return;
            }
            if (order.getGrpCopTkt4().equals("-1")) {
                order.setBz("错误:GRP_COP_TKT4匹配不到对应数字");
                return;
            }
            Integer grpCopTkt1 = Integer.valueOf(order.getGrpCopTkt1());
            Integer grpCopTkt2 = Integer.valueOf(order.getGrpCopTkt2());
            Integer grpCopTkt3 = Integer.valueOf(order.getGrpCopTkt3());
            Integer grpCopTkt4 = Integer.valueOf(order.getGrpCopTkt4());


            if (leftValue < 4 || rightValue < 4) {
                /**
                 * 类型一： (WALL_BASE_TYPE_LEFT < 4 或 WALL_BASE_TYPE_RIGHT < 4)
                 * 1100<=TK<=1500, L=TK-520. A=TK/2-165
                 * TK=1600, L=970.A=740
                 * TK=1900, L=1142.A=890
                 * TK=2100, L=1194.A=990
                 */
                Double tk = Double.valueOf(order.getTk());
                if ((1100 <= tk) && (tk <= 1500)) {
                    order.setFszd(tk - 250 + "");
                    order.setKja((tk / 2) - 165 + "");
                } else if (tk == 1600) {
                    order.setFszd("970");
                    order.setKja("740");
                } else if (tk == 1900) {
                    order.setFszd("1142");
                    order.setKja("890");
                } else if (tk == 2100) {
                    order.setFszd("1194");
                    order.setKja("990");
                } else {
                    order.setBz("错误:类型一TK无法匹配到计算公式,TK=" + tk);
                }
            } else if (((leftValue >= 4 && leftValue <= 6) || (rightValue >= 4 && rightValue <= 6)) && (grpCopTkt1 >= 1 || grpCopTkt2 >= 1)) {
                //     * 类型二：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6 ) 或(WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6 ) 和 (COP_TKT1 >=1 或 COP_TKT2>= 1)
                //     * TK=1400, L=650.A=400
                //     * TK=1500, L=750.A=450
                //     * TK=1600, L=830.A=600
                //     * TK=1900, L=1080.A=830
                //     * TK=2100, L=1150.A=950
                Double tk = Double.valueOf(order.getTk());
                if (tk == 1400) {
                    order.setFszd("650");
                    order.setKja("400");
                } else if (tk == 1500) {
                    order.setFszd("750");
                    order.setKja("450");
                } else if (tk == 1600) {
                    order.setFszd("830");
                    order.setKja("600");
                } else if (tk == 1900) {
                    order.setFszd("1080");
                    order.setKja("830");
                } else if (tk == 2100) {
                    order.setFszd("1150");
                    order.setKja("950");
                } else {
                    order.setBz("错误:类型二TK无法匹配到计算公式,TK=" + tk);
                }
            } else if (((((leftValue >= 4 && leftValue <= 6) || (rightValue >= 4 && rightValue <= 6))) && (grpCopTkt1 == 0 || grpCopTkt4 == 0) && handrailLeft == 9) || ((grpCopTkt2 == 0 || grpCopTkt3 == 0) && handrailRight == 9)) {
                /**
                 * 类型三：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6 ) 或 (WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6)和(COP_TKT1 =0 和COP_TKT4=0) 和 HANDRAIL_LEFT = 9) 或(COP_TKT2= 0 和 COP_TKT3 =0) 和 HANDRAIL_RIGHT = 9))
                 * TK >= 1250 和 TK<=1500, L=TK-644. A=TK/2-210
                 * TK=1600, L=970.A=740
                 * TK=1900, L=1142.A=890
                 * TK=2100, L=1194.A=990
                 */
                Double tk = Double.valueOf(order.getTk());
                if (tk >= 1250 && tk <= 1500) {
                    order.setFszd(tk - 644 + "");
                    order.setKja((tk / 2) - 210 + "");
                } else if (tk == 1600) {
                    order.setFszd("970");
                    order.setKja("740");
                } else if (tk == 1900) {
                    order.setFszd("1142");
                    order.setKja("890");
                } else if (tk == 2100) {
                    order.setFszd("1194");
                    order.setKja("990");
                } else {
                    order.setBz("错误:类型三TK无法匹配到计算公式,TK=" + tk);
                }
            } else {
                order.setBz("错误:类型一二三都不满足计算");
            }
        } catch (Exception e) {
            order.setBz("错误:解析错误");
        }
    }

    /**
     * 类型一：(WALL_BASE_TYPE_LEFT <4 或 WALL_BASE_TYPE_RIGHT <4)
     * TK<=1500, L=TK-520, A=TK/2-165
     * TK=1600, L=970.A=740
     * TK=1900, L=1142.A=890
     * TK=2100, L=1194,A=990
     * 类型二：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6 ) 或(W ALL_BASE_TYPE_RIGHT >=4 和 W ALL_BASE_TYPE_RIGHT<=6 )和 (COP_TKT1 >=1 or COP_TKT2>= 1)
     * TK=1400,L=650,A=400
     * TK=1500,L=750,A=450
     * TK=1600,L=830,A=600
     * TK=1900.L=1080.A=830
     * TK=2100.L=1150.A=950
     * 类型三： (WALL_BASE_TYPE_LEFT >=4 和WALL_BASE_TYPE_LEFT<=6 ) 或 (WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6 ) 和 (COP_TKT1 =0 和 COP_TKT4=0) 和 HANDRAIL_LEFT = 9) 或 (COP_TKT2= 0 和COP_TKT3 =0) 和HANDRAIL_RIGHT = 9)
     * TK >= 1250 和TK<=1500, L=TK-644, A=TK/2-210
     * TK=1600, L=970,A=740
     * TK=1900, L=1142.A=890
     * TK=2100, L=1194,A=990
     * 通用：
     * GRP_HANDRAIL_FINISH:SS304_BRUS或GRP_HANDRAIL_FINISH:SS304_HAIR     拉丝
     * GRP_HANDRAIL_FINISH:SS304_MIRR或GRP_HANDRAIL_FINISH:SS304_POLISH   镜面
     * GRP_HANDRAIL_FINISH:SS304_PAINT或GRP_HANDRAIL_FINISH:SS304_R9006    喷粉
     * 此款固定支架数量没有变值，估输出固定都为：固定支架数量：2
     * 注1：以上红色字为抓取信息，绿色为输出信息
     * 注2：如下为对应订单参数数字
     * Wall_Base_Type_Left PB对应数字1
     * Wall_Base_Type_Left HC对应数字2
     * Wall_Base_Type_Left AC对应数字3
     * Wall_Base_Type_Left SS 对应数字4 WALL_BASE_THICKNESS_LEFT = 1.0
     * Wall_Base_Type_Left ST 对应数字5
     * Wall_Base_Type_Right PB对应数字1
     * Wall_Base_Type_Right HC对应数字2
     * Wall_Base_Type_Right AC对应数字3
     * Wall_Base_Type_Right SS对应数字4 (WALL_BASE_THICKNESS_LEFT = 1.0)
     * Wall_Base_Type_Right ST 对应数字5
     * COP_TKT1或2或3或4=N                           对应数字0
     * COP_TKT1或2或3或4=COP GS 100 SF                 对应数字1
     * COP_TKT1或2或3或4=COP_GS_120_SF              对应数字2
     * COP_TKT1或2或3或4=COP_GS 100 SF_FH            对应数字3
     * COP_TKT1或2或3或4=COP_GS_100_SF_FH_PORT     对应数字4
     * COP_TKT1或2或3或4=X                         对应数字5
     * COP_TKT1或2或3或4=COP_GS_300_FL_FH         对应数字6
     * COP_TKT1或2或3或4=COP_GS_100_FL_FH         对应数字7
     *
     * @param featureMap
     * @param order
     */
    private void NO_57863882(Map<String, String> featureMap, LpsOrderLjVO order) {
        try {
            order.setTk(NumberUtils.extractValueStr(featureMap.getOrDefault(TK, "")));
            order.setGrpWallBaseTypeLeft(featureMap.getOrDefault(GRP_WALL_BASE_TYPE_LEFT, ""));
            order.setGrpWallBaseTypeRight(featureMap.getOrDefault(GRP_WALL_BASE_TYPE_RIGHT, ""));
            order.setBmcl(getBmcl(featureMap.getOrDefault(GRP_HANDRAIL_FINISH, "")));
            order.setGrpCopTkt1(getValue(featureMap.getOrDefault(GRP_COP_TKT1, "")) + "");
            order.setGrpCopTkt2(getValue(featureMap.getOrDefault(GRP_COP_TKT2, "")) + "");
            order.setGrpCopTkt3(getValue(featureMap.getOrDefault(GRP_COP_TKT3, "")) + "");
            order.setGrpCopTkt4(getValue(featureMap.getOrDefault(GRP_COP_TKT4, "")) + "");
            order.setGdzjsl("2");  //此款固定支架数量没有变值，估输出固定都为：固定支架数量：2

            Integer handrailLeft = null;
            String handrailLeftStr = featureMap.getOrDefault(HANDRAIL_LEFT, "");
            if (StrUtil.isNotBlank(handrailLeftStr)) {
                try {
                    handrailLeft = Integer.parseInt(handrailLeftStr);
                } catch (Exception e) {
                    handrailLeft = -999;
                    log.error("【利居】HANDRAIL_LEFT 解析到未知的物料{}", order.getWl());
                }
            }

            Integer handrailRight = null;
            String handrailRightStr = featureMap.getOrDefault(HANDRAIL_RIGHT, "");
            if (StrUtil.isNotBlank(handrailRightStr)) {
                try {
                    handrailRight = Integer.parseInt(handrailRightStr);
                } catch (Exception e) {
                    handrailRight = -999;
                    log.error("【利居】HANDRAIL_RIGHT 解析到未知的物料{}", order.getWl());
                }
            }

            if (StrUtil.isBlank(order.getTk())) {
                order.setBz("错误:TK为空");
                return;
            }
            if (StrUtil.isBlank(order.getGrpWallBaseTypeLeft())) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_LEFT为空");
                return;
            }
            if (StrUtil.isBlank(order.getGrpWallBaseTypeRight())) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_RIGHT为空");
                return;
            }
            Integer leftValue = getValue(order.getGrpWallBaseTypeLeft(), featureMap.getOrDefault(WALL_BASE_THICKNESS_LEFT, ""));
            if (leftValue == -1) {
                order.setBz("错误:WALL_BASE_THICKNESS_LEFT匹配不到对应数字");
                return;
            }
            order.setGrpWallBaseTypeLeft(leftValue + "");
            Integer rightValue = getValue(order.getGrpWallBaseTypeRight(), featureMap.getOrDefault(WALL_BASE_THICKNESS_LEFT, ""));
            if (rightValue == -1) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_RIGHT匹配不到对应数字");
                return;
            }
            order.setGrpWallBaseTypeRight(rightValue + "");

            if (order.getGrpCopTkt1().equals("-1")) {
                order.setBz("错误:GRP_COP_TKT1匹配不到对应数字");
                return;
            }
            if (order.getGrpCopTkt2().equals("-1")) {
                order.setBz("错误:GRP_COP_TKT2匹配不到对应数字");
                return;
            }
            if (order.getGrpCopTkt3().equals("-1")) {
                order.setBz("错误:GRP_COP_TKT3匹配不到对应数字");
                return;
            }
            if (order.getGrpCopTkt4().equals("-1")) {
                order.setBz("错误:GRP_COP_TKT4匹配不到对应数字");
                return;
            }
            Integer grpCopTkt1 = Integer.valueOf(order.getGrpCopTkt1());
            Integer grpCopTkt2 = Integer.valueOf(order.getGrpCopTkt2());
            Integer grpCopTkt3 = Integer.valueOf(order.getGrpCopTkt3());
            Integer grpCopTkt4 = Integer.valueOf(order.getGrpCopTkt4());


            if (leftValue < 4 || rightValue < 4) {
                //     * 类型一：(WALL_BASE_TYPE_LEFT <4 或 WALL_BASE_TYPE_RIGHT <4)
                //     * TK<=1500, L=TK-520, A=TK/2-165
                //     * TK=1600, L=970.A=740
                //     * TK=1900, L=1142.A=890
                //     * TK=2100, L=1194,A=990
                Double tk = Double.valueOf(order.getTk());
                if (tk <= 1500) {
                    order.setFszd(tk - 250 + "");
                    order.setKja((tk / 2) - 165 + "");
                } else if (tk == 1600) {
                    order.setFszd("970");
                    order.setKja("740");
                } else if (tk == 1900) {
                    order.setFszd("1142");
                    order.setKja("890");
                } else if (tk == 2100) {
                    order.setFszd("1194");
                    order.setKja("990");
                } else {
                    order.setBz("错误:类型一TK无法匹配到计算公式,TK=" + tk);
                }
            } else if (((leftValue >= 4 && leftValue <= 6) || (rightValue >= 4 && rightValue <= 6)) && (grpCopTkt1 >= 1 || grpCopTkt2 >= 1)) {
                //     * 类型二：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6 ) 或(W ALL_BASE_TYPE_RIGHT >=4 和 W ALL_BASE_TYPE_RIGHT<=6 )和 (COP_TKT1 >=1 or COP_TKT2>= 1)
                //     * TK=1400,L=650,A=400
                //     * TK=1500,L=750,A=450
                //     * TK=1600,L=830,A=600
                //     * TK=1900.L=1080.A=830
                //     * TK=2100.L=1150.A=950
                Double tk = Double.valueOf(order.getTk());
                if (tk == 1400) {
                    order.setFszd("650");
                    order.setKja("400");
                } else if (tk == 1500) {
                    order.setFszd("750");
                    order.setKja("450");
                } else if (tk == 1600) {
                    order.setFszd("830");
                    order.setKja("600");
                } else if (tk == 1900) {
                    order.setFszd("1080");
                    order.setKja("830");
                } else if (tk == 2100) {
                    order.setFszd("1150");
                    order.setKja("950");
                } else {
                    order.setBz("错误:类型二TK无法匹配到计算公式,TK=" + tk);
                }
            } else if (((((leftValue >= 4 && leftValue <= 6) || (rightValue >= 4 && rightValue <= 6))) && (grpCopTkt1 == 0 || grpCopTkt4 == 0) && handrailLeft == 9) || ((grpCopTkt2 == 0 || grpCopTkt3 == 0) && handrailRight == 9)) {
                //     * 类型三： (WALL_BASE_TYPE_LEFT >=4 和WALL_BASE_TYPE_LEFT<=6 ) 或 (WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6 ) 和 (COP_TKT1 =0 和 COP_TKT4=0) 和 HANDRAIL_LEFT = 9) 或 (COP_TKT2= 0 和COP_TKT3 =0) 和HANDRAIL_RIGHT = 9)
                //     * TK >= 1250 和TK<=1500, L=TK-644, A=TK/2-210
                //     * TK=1600, L=970,A=740
                //     * TK=1900, L=1142.A=890
                //     * TK=2100, L=1194,A=990
                Double tk = Double.valueOf(order.getTk());
                if (tk >= 1250 && tk <= 1500) {
                    order.setFszd(tk - 644 + "");
                    order.setKja((tk / 2) - 210 + "");
                } else if (tk == 1600) {
                    order.setFszd("970");
                    order.setKja("740");
                } else if (tk == 1900) {
                    order.setFszd("1142");
                    order.setKja("890");
                } else if (tk == 2100) {
                    order.setFszd("1194");
                    order.setKja("990");
                } else {
                    order.setBz("错误:类型三TK无法匹配到计算公式,TK=" + tk);
                }
            } else {
                order.setBz("错误:类型一二三都不满足计算");
            }
        } catch (Exception e) {
            order.setBz("错误:解析错误");
        }
    }

    /**
     * 获取表面处理
     * GRP_HANDRAIL_FINISH:SS304_BRUS或GRP_HANDRAIL_FINISH:SS304_HAIR     拉丝
     * GRP_HANDRAIL_FINISH:SS304_MIRR或GRP_HANDRAIL_FINISH:SS304_POLISH   镜面
     * GRP_HANDRAIL_FINISH:SS304_PAINT或GRP_HANDRAIL_FINISH:SS304_R9006    喷粉
     *
     * @param value
     * @return
     */
    private String getBmcl(String value) {
        if (value.equals("SS304_BRUS") || value.equals("SS304_HAIR")) {
            return "拉丝";
        } else if (value.equals("SS304_MIRR") || value.equals("SS304_POLISH")) {
            return "镜面";
        } else if (value.equals("SS304_PAINT") || value.equals("SS304_R9006")|| value.equals("SS_PAI_R9006")) {
            return "喷粉";
        } else {
            return "错误";
        }
    }

    /**
     * GRP_COP_TKT1或2或3或4=N                           对应数字0
     * GRP_COP_TKT1或2或3或4=COP GS 100 SF                 对应数字1
     * GRP_COP_TKT1或2或3或4=COP_GS_120_SF              对应数字2
     * GRP_COP_TKT1或2或3或4=COP_GS 100 SF_FH            对应数字3
     * GRP_COP_TKT1或2或3或4=COP_GS_100_SF_FH_PORT     对应数字4
     * GRP_COP_TKT1或2或3或4=X                         对应数字5
     * GRP_COP_TKT1或2或3或4=COP_GS_300_FL_FH         对应数字6
     * GRP_COP_TKT1或2或3或4=COP_GS_100_FL_FH         对应数字7
     */
    private Integer getValue(String value) {
        if (value.equals("N")) {
            return 0;
        } else if (value.equals("COP_GS_100_SF")) {
            return 1;
        } else if (value.equals("COP_GS_120_SF")) {
            return 2;
        } else if (value.equals("COP_GS 100 SF_FH") || value.equals("COP_GS_100_SF_FH")) {
            return 3;
        } else if (value.equals("COP_GS_100_SF_FH_PORT")) {
            return 4;
        } else if (value.equals("X")) {
            return 5;
        } else if (value.equals("COP_GS_300_FL_FH")) {
            return 6;
        } else if (value.equals("COP_GS_100_FL_FH")) {
            return 7;
        } else {
            return -1;
        }
    }

    /**
     * GRP_WALL_BASE_TYPE_LEFT PB对应数字1
     * GRP_WALL_BASE_TYPE_LEFT HC对应数字2
     * GRP_WALL_BASE_TYPE_LEFT AC对应数字3
     * GRP_WALL_BASE_TYPE_LEFT SS 跟 WALL_BASE_THICKNESS_LEFT = 1.0 对应数字4
     * GRP_WALL_BASE_TYPE_LEFT ST 对应数字5
     * GRP_WALL_BASE_TYPE_LEFT SS 跟 WALL_BASE_THICKNESS_LEFT = 1.2 对应数字6
     * GRP_WALL_BASE_TYPE_RIGHT PB对应数字1
     * GRP_WALL_BASE_TYPE_RIGHT HC对应数字2
     * GRP_WALL_BASE_TYPE_RIGHT AC对应数字3
     * GRP_WALL_BASE_TYPE_RIGHT SS 跟 WALL_BASE_THICKNESS_LEFT = 1.0 对应数字4l
     * GRP_WALL_BASE_TYPE_RIGHT ST 对应数字5
     * GRP_WALL_BASE_TYPE_RIGHT SS 跟 WALL_BASE_THICKNESS_LEFT = 1.2 对应数字6
     *
     * @param value
     * @param otherValue
     * @return
     */
    private Integer getValue(String value, String otherValue) {
        if (value.equals("PB")) {
            return 1;
        } else if (value.equals("HC")) {
            return 2;
        } else if (value.equals("AC")) {
            return 3;
        } else if (value.equals("SS") && otherValue.equals("1.0")) {
            return 4;
        } else if (value.equals("ST")) {
            return 5;
        } else if (value.equals("SS") && otherValue.equals("1.2")) {
            return 6;
        } else if (value.equals("SS")) {
            return 4;
        } else {
            return -1;
        }
    }

    /**
     * 类型一：TK<=1500, L=TK-250.A=678. B=0 , 固定支架数量：2
     * TK=1600, L=TK-222.A=760. B=1200, 固定支架数量：4
     * TK>1700, L=TK-250.A=760. B=1200, 固定支架数量：4
     * 类型二：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6) 或(WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6 )
     * TK=1500, L=TK-250.A=678.B=0, 固定支架数量：2
     * TK=1600, L=TK-222.A=678.B=1200, 固定支架数量：4
     * TK>1700, L=TK-250.A=678.B=1200., 固定支架数量：4
     * 通用：
     * GRP_HANDRAIL_FINISH:SS304_BRUS或GRP_HANDRAIL_FINISH:SS304_HAIR     拉丝
     * GRP_HANDRAIL_FINISH:SS304_MIRR或GRP_HANDRAIL_FINISH:SS304_POLISH   镜面
     * GRP_HANDRAIL_FINISH:SS304_PAINT或GRP_HANDRAIL_FINISH:SS304_R9006    喷粉
     * 注：如下为对应订单参数数字
     * Wall_Base_Type_Left PB对应数字1
     * Wall_Base_Type_Left HC对应数字2
     * Wall_Base_Type_Left AC对应数字3
     * Wall_Base_Type_Left SS 对应数字4 WALL_BASE_THICKNESS_LEFT = 1.0
     * Wall_Base_Type_Left ST 对应数字5
     * Wall_Base_Type_Left SS 对应数字6 WALL_BASE_THICKNESS_LEFT = 1.2
     * Wall_Base_Type_Right PB对应数字1
     * Wall_Base_Type_Right HC对应数字2
     * Wall_Base_Type_Right AC对应数字3
     * Wall_Base_Type_Right SS对应数字4 (WALL_BASE_THICKNESS_LEFT = 1.0)
     * Wall_Base_Type_Right ST 对应数字5
     * Wall_Base_Type_Right SS 对应数字6 (WALL_BASE_THICKNESS_LEFT = 1.2)
     *
     * @param featureMap
     * @param order
     */
    private void NO_57628558(Map<String, String> featureMap, LpsOrderLjVO order) {
        try {
            order.setTk(NumberUtils.extractValueStr(featureMap.getOrDefault(TK, "")));
            order.setGrpWallBaseTypeLeft(featureMap.getOrDefault(GRP_WALL_BASE_TYPE_LEFT, ""));
            order.setGrpWallBaseTypeRight(featureMap.getOrDefault(GRP_WALL_BASE_TYPE_RIGHT, ""));
            order.setBmcl(getBmcl(featureMap.getOrDefault(GRP_HANDRAIL_FINISH, "")));
            if (StrUtil.isBlank(order.getTk())) {
                order.setBz("错误:TK为空");
                return;
            }
            if (StrUtil.isBlank(order.getGrpWallBaseTypeLeft())) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_LEFT为空");
                return;
            }
            if (StrUtil.isBlank(order.getGrpWallBaseTypeRight())) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_RIGHT为空");
                return;
            }
            Integer leftValue = getValue(order.getGrpWallBaseTypeLeft(), featureMap.getOrDefault(WALL_BASE_THICKNESS_LEFT, ""));
            if (leftValue == -1) {
                order.setBz("错误:WALL_BASE_THICKNESS_LEFT匹配不到对应数字");
                return;
            }
            order.setGrpWallBaseTypeLeft(leftValue + "");
            Integer rightValue = getValue(order.getGrpWallBaseTypeRight(), featureMap.getOrDefault(WALL_BASE_THICKNESS_LEFT, ""));
            if (rightValue == -1) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_RIGHT匹配不到对应数字");
                return;
            }
            order.setGrpWallBaseTypeRight(rightValue + "");
            //类型二
            if ((leftValue >= 4 && leftValue <= 6) || (rightValue >= 4 && rightValue <= 6)) {
                double tk = Double.parseDouble(order.getTk());
                if (tk <= 1500) {
                    //TK<=>1500, L=TK-250.A=678.B=0, 固定支架数量：2
                    order.setFszd(tk - 250 + "");
                    order.setKja("678");
                    order.setKjb("0");
                    order.setGdzjsl("2");
                } else if (tk == 1600) {
                    //TK=1600, L=TK-222.A=678.B=1200, 固定支架数量：4
                    order.setFszd(tk - 222 + "");
                    order.setKja("678");
                    order.setKjb("1200");
                    order.setGdzjsl("4");
                } else if (tk > 1700) {
                    //TK>1700, L=TK-250.A=678.B=1200., 固定支架数量：4
                    order.setFszd(tk - 250 + "");
                    order.setKja("678");
                    order.setKjb("1200");
                    order.setGdzjsl("4");
                } else {
                    order.setBz("错误:类型二TK无法匹配到计算公式,TK=" + tk);
                }
            } else {
                //类型一
                double tk = Double.parseDouble(order.getTk());
                if (tk <= 1500) {
                    //TK<=1500, L=TK-250.A=678. B=0 , 固定支架数量：2
                    //扶手长度(L)
                    order.setFszd(tk - 250 + "");
                    order.setKja("678");
                    order.setKjb("0");
                    //固定支架数量
                    order.setGdzjsl("2");
                } else if (tk == 1600) {
                    //TK=1600, L=TK-222.A=760. B=1200, 固定支架数量：4
                    //扶手长度(L)
                    order.setFszd(tk - 222 + "");
                    order.setKja("760");
                    order.setKjb("1200");
                    //固定支架数量
                    order.setGdzjsl("4");
                } else if (tk > 1700) {
                    //TK>1700, L=TK-250.A=760. B=1200, 固定支架数量：4
                    //扶手长度(L)
                    order.setFszd(tk - 250 + "");
                    order.setKja("760");
                    order.setKjb("1200");
                    //固定支架数量
                    order.setGdzjsl("4");
                } else {
                    order.setBz("错误:类型一TK无法匹配到计算公式,TK=" + tk);
                }
            }
        } catch (Exception e) {
            order.setBz("错误:解析错误");
        }
    }

    /**
     * 类型一：(WALL_BASE_TYPE_LEFT <4 或 WALL_BASE_TYPE_RIGHT <4)
     * TK>1500, A=760. B=1200 固定支架数量：4，L=TK-165
     * TK<=1500, A=0. B=678 固定支架数量：2，L=TK-165
     * <p>
     * 类型二：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6 ) 或(WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6 )
     * TK<=1500,A=0. B=678 固定支架数量：2，L=TK-165
     * TK>1500,A=678. B=1200 固定支架数量：4，L=TK-165
     * 通用：
     * GRP_HANDRAIL_FINISH:SS304_BRUS或GRP_HANDRAIL_FINISH:SS304_HAIR     拉丝
     * GRP_HANDRAIL_FINISH:SS304_MIRR或GRP_HANDRAIL_FINISH:SS304_POLISH   镜面
     * GRP_HANDRAIL_FINISH:SS304_PAINT或GRP_HANDRAIL_FINISH:SS304_R9006    喷粉
     * 注1：以上红色字为抓取信息，绿色为输出信息
     * 注2：如下为对应订单参数数字
     * Wall_Base_Type_Left PB对应数字1
     * Wall_Base_Type_Left HC对应数字2
     * Wall_Base_Type_Left AC对应数字3
     * Wall_Base_Type_Left SS 对应数字4 WALL_BASE_THICKNESS_LEFT = 1.0
     * Wall_Base_Type_Left ST 对应数字5
     * Wall_Base_Type_Right PB对应数字1
     * Wall_Base_Type_Right HC对应数字2
     * Wall_Base_Type_Right AC对应数字3
     * Wall_Base_Type_Right SS对应数字4 (WALL_BASE_THICKNESS_LEFT = 1.0)
     * Wall_Base_Type_Right ST 对应数字5
     * COP_TKT1或2或3或4=N                           对应数字0
     * COP_TKT1或2或3或4=COP GS 100 SF                 对应数字1
     * COP_TKT1或2或3或4=COP_GS_120_SF              对应数字2
     * COP_TKT1或2或3或4=COP_GS 100 SF_FH            对应数字3
     * COP_TKT1或2或3或4=COP_GS_100_SF_FH_PORT     对应数字4
     * COP_TKT1或2或3或4=X                         对应数字5
     * COP_TKT1或2或3或4=COP_GS_300_FL_FH         对应数字6
     * COP_TKT1或2或3或4=COP_GS_100_FL_FH         对应数字7
     *
     * @param featureMap
     * @param order
     */
    private void NO_57863883(Map<String, String> featureMap, LpsOrderLjVO order) {
        try {
            order.setTk(NumberUtils.extractValueStr(featureMap.getOrDefault(TK, "")));
            order.setGrpWallBaseTypeLeft(featureMap.getOrDefault(GRP_WALL_BASE_TYPE_LEFT, ""));
            order.setGrpWallBaseTypeRight(featureMap.getOrDefault(GRP_WALL_BASE_TYPE_RIGHT, ""));
            order.setBmcl(getBmcl(featureMap.getOrDefault(GRP_HANDRAIL_FINISH, "")));
            if (StrUtil.isBlank(order.getTk())) {
                order.setBz("错误:TK为空");
                return;
            }
            if (StrUtil.isBlank(order.getGrpWallBaseTypeLeft())) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_LEFT为空");
                return;
            }
            if (StrUtil.isBlank(order.getGrpWallBaseTypeRight())) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_RIGHT为空");
                return;
            }
            Integer leftValue = getValue(order.getGrpWallBaseTypeLeft(), featureMap.getOrDefault(WALL_BASE_THICKNESS_LEFT, ""));
            if (leftValue == -1) {
                order.setBz("错误:WALL_BASE_THICKNESS_LEFT匹配不到对应数字");
                return;
            }
            order.setGrpWallBaseTypeLeft(leftValue + "");
            Integer rightValue = getValue(order.getGrpWallBaseTypeRight(), featureMap.getOrDefault(WALL_BASE_THICKNESS_LEFT, ""));
            if (rightValue == -1) {
                order.setBz("错误:GRP_WALL_BASE_TYPE_RIGHT匹配不到对应数字");
                return;
            }
            order.setGrpWallBaseTypeRight(rightValue + "");
            //类型二：(WALL_BASE_TYPE_LEFT >=4 和 WALL_BASE_TYPE_LEFT<=6 ) 或(WALL_BASE_TYPE_RIGHT >=4 和 WALL_BASE_TYPE_RIGHT<=6 )
            if ((leftValue >= 4 && leftValue <= 6) || (rightValue >= 4 && rightValue <= 6)) {
                double tk = Double.parseDouble(order.getTk());
                if (tk <= 1500) {
                    //TK<=1500,A=0. B=678 固定支架数量：2，L=TK-165
                    order.setFszd(tk - 165 + "");
                    order.setKja("0");
                    order.setKjb("678");
                    order.setGdzjsl("2");
                } else {
                    //TK>1500,A=678. B=1200 固定支架数量：4，L=TK-165
                    order.setFszd(tk - 165 + "");
                    order.setKja("678");
                    order.setKjb("1200");
                    order.setGdzjsl("4");
                }
            } else {
                //类型一：(WALL_BASE_TYPE_LEFT <4 或 WALL_BASE_TYPE_RIGHT <4)
                double tk = Double.parseDouble(order.getTk());
                if (tk <= 1500) {
                    //TK<=1500, A=0. B=678 固定支架数量：2，L=TK-165
                    order.setFszd(tk - 165 + "");
                    order.setKja("0");
                    order.setKjb("678");
                    order.setGdzjsl("2");
                } else {
                    //TK>1500, A=760. B=1200 固定支架数量：4，L=TK-165
                    order.setFszd(tk - 165 + "");
                    order.setKja("760");
                    order.setKjb("1200");
                    order.setGdzjsl("4");
                }
            }
        } catch (Exception e) {
            order.setBz("错误:解析错误");
        }
    }

    /**
     * 1100 < = BK < = 1500,L=BK-200. A=678, B=0 固定支架数量：2
     * BK>1500 ,L=BK-200. A=678, B=1200 固定支架数量：4
     * 通用：
     * GRP_HANDRAIL_FINISH:SS304_BRUS或GRP_HANDRAIL_FINISH:SS304_HAIR     拉丝
     * GRP_HANDRAIL_FINISH:SS304_MIRR或GRP_HANDRAIL_FINISH:SS304_POLISH   镜面
     * GRP_HANDRAIL_FINISH:SS304_PAINT或GRP_HANDRAIL_FINISH:SS304_R9006    喷粉
     *
     * @param featureMap
     * @param order
     */
    private void NO_57863727(Map<String, String> featureMap, LpsOrderLjVO order) {
        try {
            order.setBk(NumberUtils.extractValueStr(featureMap.getOrDefault(BK, "")));
            order.setBmcl(getBmcl(featureMap.getOrDefault(GRP_HANDRAIL_FINISH, "")));
            if (StrUtil.isBlank(order.getBk())) {
                order.setBz("错误:BK为空");
                return;
            }
            Double bk = Double.valueOf(order.getBk());
            if (bk >= 1100 && bk <= 1500) {
                order.setFszd(bk - 200 + "");
                order.setKja("678");
                order.setGdzjsl("2");
            } else if (bk > 1500) {
                order.setFszd(bk - 200 + "");
                order.setKja("678");
                order.setKjb("1200");
                order.setGdzjsl("4");
            } else {
                order.setBz("错误:BK无法匹配到计算公式,BK=" + bk);
            }

        } catch (Exception e) {
            order.setBz("错误:解析错误");
        }
    }

    /**
     * BK>1500 , A=678. B=1200. 扶手长度=(BK-200- x - y) 固定支架数量：4
     * 1050<=BK<=1500, A=678. 扶手长度=(BK-200- x - y) 固定支架数量：2
     * 950<=BK<1050, A=678.扶手长度=(BK-100- x - y) 固定支架数量：2
     * X=TKWC_LEFT+TKWO_LEFT
     * Y=TKWC_RIGHT+TKWO_RIGHT
     * GRP_HANDRAIL_FINISH:SS304_BRUS或GRP_HANDRAIL_FINISH:SS304_HAIR     拉丝
     * GRP_HANDRAIL_FINISH;SS304_MIRR或GRP_HANDRAIL_FINISH:SS304_POLISH   镜面
     * GRP_HANDRAIL_FINISH:SS304_PAINT或GRP_HANDRAIL_FINISH:SS304_R9006    喷粉
     *
     * @param featureMap
     * @param order
     */
    private void NO_57863726(Map<String, String> featureMap, LpsOrderLjVO order) {
        try {
            order.setBk(NumberUtils.extractValueStr(featureMap.getOrDefault(BK, "")));
            order.setBmcl(getBmcl(featureMap.getOrDefault(GRP_HANDRAIL_FINISH, "")));
            order.setTkwoRight(NumberUtils.extractValueStr(featureMap.getOrDefault(TKWO_RIGHT, "")));
            order.setTkwcRight(NumberUtils.extractValueStr(featureMap.getOrDefault(TKWC_RIGHT, "")));
            order.setTkwoLeft(NumberUtils.extractValueStr(featureMap.getOrDefault(TKWO_LEFT, "")));
            order.setTkwcLeft(NumberUtils.extractValueStr(featureMap.getOrDefault(TKWC_LEFT, "")));

            if (StrUtil.isBlank(order.getBk())) {
                order.setBz("错误:BK为空");
                return;
            }
            if (StrUtil.isBlank(order.getTkwoRight())) {
                order.setBz("错误:TKWO_RIGHT为空");
            }
            if (StrUtil.isBlank(order.getTkwcRight())) {
                order.setBz("错误:TKWC_RIGHT为空");
            }
            if (StrUtil.isBlank(order.getTkwoLeft())) {
                order.setBz("错误:TKWO_LEFT为空");
            }
            if (StrUtil.isBlank(order.getTkwcLeft())) {
                order.setBz("错误:TKWC_LEFT为空");
            }
            double bk = Double.parseDouble(order.getBk());

            BigDecimal tkwoRight = new BigDecimal(order.getTkwoRight());
            BigDecimal tkwcRight = new BigDecimal(order.getTkwcRight());

            BigDecimal tkwoLeft = new BigDecimal(order.getTkwoLeft());
            BigDecimal tkwcLeft = new BigDecimal(order.getTkwcLeft());
            //X=TKWC_LEFT+TKWO_LEFT
            BigDecimal x = tkwcLeft.add(tkwoLeft);
            //Y=TKWC_RIGHT+TKWO_RIGHT
            BigDecimal y = tkwcRight.add(tkwoRight);

            BigDecimal bkDecimal = new BigDecimal(bk);

            if (bk >= 950 && bk < 1050) {
                //950<=BK<1050, A=678.扶手长度=(BK-100 - x - y) 固定支架数量：2
                BigDecimal fszd = NumberUtil.sub(bkDecimal, NumberUtil.add(100, x, y));
                order.setFszd(fszd + "");
                order.setKja("678");
                order.setGdzjsl("2");
            } else if (bk >= 1050 && bk <= 1500) {
                //11050<=BK<=1500, A=678. 扶手长度=(BK-200- x - y) 固定支架数量：2
                BigDecimal fszd = NumberUtil.sub(bkDecimal, NumberUtil.add(200, x, y));
                order.setFszd(fszd + "");
                order.setKja("678");
                order.setGdzjsl("2");
            } else if (bk > 1500) {
                //BK>1500 , A=678. B=1200. 扶手长度=(BK-200- x - y) 固定支架数量：4
                BigDecimal fszd = NumberUtil.sub(bkDecimal, NumberUtil.add(200, x, y));
                order.setFszd(fszd + "");
                order.setKja("678");
                order.setKjb("1200");
                order.setGdzjsl("4");
            } else {
                order.setBz("错误:BK无法匹配到计算公式,BK=" + bk);
            }
        } catch (Exception e) {
            order.setBz("错误:解析错误");
        }
    }
}
